package wwl.lsf;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

public class MyWebApplicationInitaler implements WebApplicationInitializer {

  @Override
  public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext applicationContext =
        new AnnotationConfigWebApplicationContext();
    applicationContext.register(AppConfig.class);
    applicationContext.refresh();
    DispatcherServlet dispatcherServlet = new DispatcherServlet(applicationContext);
    Dynamic wwlDis = servletContext.addServlet("wwl", dispatcherServlet);
    wwlDis.addMapping("*.do");
    wwlDis.setLoadOnStartup(1);
  }
}
